//
//  main.m
//  oc_28
//
//  Created by 楼楚 on 15/9/18.
//  Copyright (c) 2015年 Chu Lou. All rights reserved.
//

#import <Foundation/Foundation.h>
#define PATH @"/Users/louchu/code/oc_exercise/test"

int main(int argc, const char * argv[]) {
    @autoreleasepool {
//        NSFileHandle *hf = [NSFileHandle fileHandleForReadingAtPath:[NSString stringWithFormat:@"%@/hello",PATH]];
//     
//        
//        NSData *data = [hf readDataOfLength:3];
//        NSString *str = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
//        NSLog(@"%@",str);
//        
//        
//        NSData *data1 = [hf readDataToEndOfFile];
//        NSString *str1 = [[NSString alloc]initWithData:data1 encoding:NSUTF8StringEncoding];
//        NSLog(@"%@",str1);
        
        NSFileHandle *wHf = [NSFileHandle fileHandleForWritingAtPath:[NSString stringWithFormat:@"%@/hello",PATH]];
        [wHf seekToEndOfFile];//  把光标移到句尾
//        
//        NSData *data2 = [@"sss" dataUsingEncoding:NSUTF8StringEncoding];
//        [wHf writeData:data2];
       
        
        NSData *data3 = [@"dd dd ddd" dataUsingEncoding:NSUTF8StringEncoding];
        [wHf writeData:data3];

    }
    return 0;
}
